package designpatterns.memento;

import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

/**
 * @author LiDong
 * @version 1.0.0
 * @createTime 2/17/2022 7:38 PM
 */
@Slf4j
public class AppTest {

    @Test
    public void test() {
        Originator originator = new Originator();
        CareTaker careTaker = new CareTaker();
        originator.setState("State #1");
        originator.setState("State #2");
        careTaker.add(originator.saveStateToMemento());
        originator.setState("State #3");
        careTaker.add(originator.saveStateToMemento());
        originator.setState("State #4");

        log.info("Current State: " + originator.getState());
        originator.getStateFromMemento(careTaker.get(0));
        log.info("First saved State: " + originator.getState());
        originator.getStateFromMemento(careTaker.get(1));
        log.info("Second saved State: " + originator.getState());
    }
}
